package com.atguigu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.base.BaseDAO;
import com.atguigu.base.BaseServiceImpl;
import com.atguigu.dao.HouseImageDAO;
import com.atguigu.entity.HouseImage;
import com.atguigu.service.HouseImageService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @PACKAGE_NAME: com.atguigu.service.impl
 * @CLASSNAME: HouseImageServiceImpl
 * @AUTHOR: zhangsan
 * @DATE: 2024/4/23 15:39
 * @SINCE 17.0.7
 * @DESCRIPTION: HouseImageServiceImpl
 */
@Service(interfaceClass = HouseImageService.class)
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class HouseImageServiceImpl extends BaseServiceImpl<HouseImage> implements HouseImageService {

    @Resource
    private HouseImageDAO houseImageDAO;

    @Override
    protected BaseDAO<HouseImage> getEntityDAO() {
        return houseImageDAO;
    }

    /**
     * 根据房源id和图片类型,查找房源对应的图片
     * type tinyInt 类型 1 表示普通图片 2 表示房产图片
     *
     * @param id
     * @param i
     * @return
     */
    @Override
    public List<HouseImage> findListByHouseIdAndType(Long houseId, Integer type) {
        List<HouseImage> houseImageList = houseImageDAO.findListByHouseIdAndType(houseId, type);
        return houseImageList;
    }
}
